<?php

namespace App\Models\FilterableAssetBundle;

use App\Models\Attachment;
use Hyn\Tenancy\Traits\UsesTenantConnection;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\FilterableAssetBundle\FilterableAssetBundle
 *
 * @property int $id
 * @property string $name
 * @property string $description
 * @property int $created_by
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property string|null $deleted_at
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Attachment[] $attachments
 * @property-read int|null $attachments_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\FilterableAssetBundle\FilterableAssetBundleCriterion[] $criteria
 * @property-read int|null $criteria_count
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle whereCreatedBy($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle whereDescription($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FilterableAssetBundle\FilterableAssetBundle whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class FilterableAssetBundle extends Model
{
    use UsesTenantConnection;
    protected $guarded = [];

    public function attachments()
    {
        return $this->morphMany(Attachment::class, 'attachable');
    }

    public function criteria()
    {
        return $this->hasMany(FilterableAssetBundleCriterion::class, "bundle_id");
    }
}
